package com.shiguiwu.springmybatis.designpattern.factorymethod;

/**
 * @description: 工厂方法
 * 定义：定义一个创建对象的接口，但让实现接口的类决定具体实例化哪个类。
 * 工厂方法让类的实例化延迟到子类中进行。
 * jdk应用的改设计模式有Collection的Iterator<E> iterator()方法;
 * @author: stone
 * @date: Created by 2021/2/19 14:54
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.factorymethod
 */
public class FactoryMethodTests {

    public static void main(String[] args) {
        VideoFactory videoFactory = new JavaVideoFactory();
        Video video = videoFactory.getVideo();
        video.produce();
        VideoFactory videoFactory1 = new PythonVideoFactory();
        Video video1 = videoFactory1.getVideo();
        video1.produce();

//        VideoFactory videoFactory2 = new VideoFactory() {
//            @Override
//            public Video getVideo() {
//                return null;
//            }
//
//        };

        VideoFactory videoFactory2 = DbVideo::new;//DbVideo::new;
        Video video2 = videoFactory2.getVideo();
        video2.produce();


    }
}
